package JLB_Chapter_07;


class Quadrangle {
    public static void draw(Quadrangle q){
        System.out.println("画一个四边形");
    }
}
class Square extends Quadrangle {
    public static void main(Square s) {
        System.out.println("画一个Square");
    }
}
class Anything {
}
public class Parallelogram extends Quadrangle {
    public static void main(String[] args) {
        Parallelogram p = new Parallelogram();
        draw(p);
        Quadrangle q = new Quadrangle();
//        Parallelogram exap = (Parallelogram) q;
        if(q instanceof Parallelogram) {
            Parallelogram exap1 = (Parallelogram) q;
        }
        if(q instanceof  Square) {
            Parallelogram exap2 = (Parallelogram) q;
        }
        // 因为q对象不是Anything类的对象，所以这条语句是错误的
        // System.out.println(q instanceof Anything);
    }
}
